#include <sys_config.h>
#include <osal/osal.h>
#include <basic_types.h>
#include <mediatypes.h>

#include <api/libc/printf.h>
#include <api/libc/alloc.h>
#include <api/libc/string.h>

#include <hld/hld_dev.h>
#include <hld/vbi/vbi.h>
#include <hld/vbi/vbi_dev.h>
#include <hld/dis/VPO.h>
#include <hal/hal_common.h>

#include "vbi_buffer.h"
#include "vbi_m3327.h"

#ifdef DUAL_ENABLE
#include <modules.h>

enum LLD_VBI_FUNC{
    FUNC_VBI_M33_ATTACH = 0,   
    FUNC_VBI_M33_ENABLE_TTX_BY_OSD,
    FUNC_VBI_M33_ENABLE_VBI_TRANSFER,
    FUNC_VBI_M33_GET_INITIAL_PAGE,
    FUNC_VBI_M33_GET_INITIAL_PAGE_STATUS,
    FUNC_VBI_M33_GET_FIRST_TTX_PAGE,
};

#ifndef _LLD_VBI_M33_REMOTE

INT32 vbi_m33_attach(struct vbi_config_par *config_par);
void vbi_enable_ttx_by_osd(struct vbi_device*pdev);
void enable_vbi_transfer(BOOL enable);
UINT16 get_inital_page();
UINT8 get_inital_page_status();
UINT16 get_first_ttx_page();

UINT32 lld_vbi_m36_entry[] = 
{
    (UINT32)vbi_m33_attach,
    (UINT32)vbi_enable_ttx_by_osd,
    (UINT32)enable_vbi_transfer,
    (UINT32)get_inital_page,
    (UINT32)get_inital_page_status,
    (UINT32)get_first_ttx_page,
};

void lld_vbi_m33_callee(UINT8 *msg)
{
    OS_hld_callee(lld_vbi_m36_entry, msg);
}
#endif

#ifdef _LLD_VBI_M33_REMOTE

static UINT32 desc_cfg_param[] = 
{ //desc of pointer para
  1, DESC_STATIC_STRU(0, sizeof(struct vbi_config_par)), 
  1, DESC_P_PARA(0, 0, 0), 
  //desc of pointer ret
  0,                          
  0,
};

INT32 vbi_m33_attach(struct vbi_config_par * cfg_param)
{
    jump_to_func(NULL, OS_hld_caller, cfg_param, (LLD_VBI_M33_MODULE<<24)|(1<<16)|FUNC_VBI_M33_ATTACH, desc_cfg_param);
}

void vbi_enable_ttx_by_osd(struct vbi_device*pdev)
{
    jump_to_func(NULL, OS_hld_caller, pdev, (LLD_VBI_M33_MODULE<<24)|(1<<16)|FUNC_VBI_M33_ENABLE_TTX_BY_OSD, NULL);
}

void enable_vbi_transfer(BOOL enable)
{
    jump_to_func(NULL, OS_hld_caller, enable, (LLD_VBI_M33_MODULE<<24)|(1<<16)|FUNC_VBI_M33_ENABLE_VBI_TRANSFER, NULL);
}

UINT16 get_inital_page()
{
    jump_to_func(NULL, OS_hld_caller, null, (LLD_VBI_M33_MODULE<<24)|(0<<16)|FUNC_VBI_M33_GET_INITIAL_PAGE, NULL);
}

UINT8 get_inital_page_status()
{
    jump_to_func(NULL, OS_hld_caller, null, (LLD_VBI_M33_MODULE<<24)|(0<<16)|FUNC_VBI_M33_GET_INITIAL_PAGE_STATUS, NULL);
}

UINT16 get_first_ttx_page()
{
    jump_to_func(NULL, OS_hld_caller, null, (LLD_VBI_M33_MODULE<<24)|(0<<16)|FUNC_VBI_M33_GET_FIRST_TTX_PAGE, NULL);
}
#endif

#endif

